-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[evm] refactor evm parameters #3958
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3958 +/- ##
==========================================
+ Coverage 75.38% 76.17% +0.79%
==========================================
Files 303 328 +25
Lines 25923 27982 +2059
==========================================
+ Hits 19541 21316 +1775
- Misses 5360 5570 +210
- Partials 1022 1096 +74
... and 3 files with indirect coverage changes 📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
action/protocol/execution/evm/evm.go
Outdated
retval, depositGas, remainingGas, contractAddress, statusCode, err := executeInEVM(ctx, ps, stateDB, g.Blockchain, blkCtx.GasLimit, blkCtx.BlockHeight) | ||
actionCtx := ps.actionCtx | ||
blkCtx := ps.blkCtx | ||
featureCtx := ps.featureCtx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directly use ps.actionCtx/blkCtx/featureCtx
action/protocol/execution/evm/evm.go
Outdated
config = vmCfg | ||
} | ||
chainConfig := getChainConfig(g, blockHeight, evmParams.evmNetworkID) | ||
config := evmParams.evmConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directly use evmParams.evmConfig
since it is only used 1 time
action/protocol/execution/evm/evm.go
Outdated
} | ||
chainConfig := getChainConfig(g, blockHeight, evmParams.evmNetworkID) | ||
config := evmParams.evmConfig | ||
chainConfig := evmParams.chainConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to L426 together
action/protocol/execution/evm/evm.go
Outdated
func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, uint64, string, iotextypes.ReceiptStatus, error) { | ||
gasLimit := evmParams.blkCtx.GasLimit | ||
blockHeight := evmParams.blkCtx.BlockHeight | ||
g := evmParams.genesis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks better to group together
var (
gasLimit
....
)
action/protocol/execution/evm/evm.go
Outdated
@@ -105,6 +111,7 @@ func newParams( | |||
actionCtx := protocol.MustGetActionCtx(ctx) | |||
blkCtx := protocol.MustGetBlockCtx(ctx) | |||
featureCtx := protocol.MustGetFeatureCtx(ctx) | |||
g := genesis.MustExtractGenesisContext(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks better to group together
var (
actionCtx
...
)
action/protocol/execution/evm/evm.go
Outdated
@@ -162,6 +169,12 @@ func newParams( | |||
Difficulty: new(big.Int).SetUint64(uint64(50)), | |||
BaseFee: new(big.Int), | |||
} | |||
evmNetworkID := protocol.MustGetBlockchainCtx(ctx).EvmNetworkID | |||
vmConfig := vm.Config{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to L114
action/protocol/execution/evm/evm.go
Outdated
blkCtx protocol.BlockCtx | ||
genesis genesis.Blockchain | ||
featureCtx protocol.FeatureCtx | ||
actionCtx protocol.ActionCtx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L89 executorRawAddress string
can be deleted, defined but not used at all
action/protocol/execution/evm/evm.go
Outdated
vmConfig vm.Config | ||
contractAddrPointer *common.Address | ||
getHashFn vm.GetHashFunc | ||
) | ||
executorAddr := common.BytesToAddress(actionCtx.Caller.Bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L122 move to L116
SonarCloud Quality Gate failed. 0 Bugs No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Description
To ensure easier code maintenance in EVM, the
Params
struct is used internally to access the required parameters.Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: